<?php 
$util = new Util();
$charset = $util->getCharset();
if(!isset($hide))
	$hide = array();
	
?>
<div class="showTable">
  <?php
	if($objDef->showExtraTemplate!=''){
		include_partial($objDef->showExtraTemplate, array('self'=>$self, 'objDef' => $objDef)); 
	}?>
	  <?php echo $objDef->renderDefault($self,$hide,'div',true) ?>
</div>      
<hr />
<!-- Items del objeto -->
<?php foreach($objDef->attributes as $fieldName => $att):?>
	  <?php if($att['type']=='List' and $att['show']):?>
      <?php 
      		if($att['relationType']==''){
      			/*Es la relacion principal, va del id de este objeto al owner del item...
      			 * El nombre del atributo tiene que ser igual al foreignalias del atributo que vincula al item
      			 * */
				$relations = $self->getTable()->getRelations();
 	  			if(isset($relatedObjDef))
    				unset($relatedObjDef);
				foreach ($relations as $name => $relation) {
					if($relation->getType() == 1){
		    			if($fieldName==$name){
		    				$sf_user->setAttribute('ownerId',$self->id);
    						$sf_user->setAttribute('ownerClass',$className);
    						$sf_user->setAttribute('ownerModule',$module);
    						$relatedClass = $relation->getClass();
    						$relatedObjDef = new objectDef($relatedClass);
    						$addNew = !$att['readOnly'];
    						echo $relatedObjDef->renderListTable($self->$name, $module, null, true, $addNew);
    						$fieldName = $name;
		    			}
					}
				}
      		}?>
  <?php endif;?>
<?php endforeach;?>
<?php 
	$q = Doctrine::getTable('attachment')
		->createQuery('m')
		->where('owner_id= ?',$self->id)
		->andWhere("ownerclass = ?",get_class($self));
	$q->setHydrationMode(Doctrine_Core::HYDRATE_ARRAY);	
	$records =	$q->execute();
	if(count($records) > 0)
	{
		$objectDef = new objectDef('attachment');
		echo $objectDef->renderListTable($records,$module,array('public'),true,false,false);
	}
?>
<div id="buttons">
	<div class="innerButtons">
      <a id="confirm" style="float:right;" onclick="$.fancybox.close();" href="#">
      <img src="/images/icons/64/confirm.png" title="<?php echo __('Go Back')?> " />
      </a>
      <?php if($objDef->canBeDeleted):?>
      	 <a id="deleteItem" style="float:right;" onclick="deleteItem('<?php echo get_class($self); ?>', ', <?php echo $self->id;?>);" href="#">
      	 <!-- <img src="/images/icons/64/delete.png" title="<?php echo __('Delete')?> "/>  -->	
      	 </a>
      <?php endif;?>
	</div>  
</div>